﻿using Dos.ORM;
using JT808.Repository.Models;
using Microsoft.Extensions.Options;
using System;

namespace JT808.Repository
{
    public class JT808DataRepository
    {
        private DbSession Context;
        public JT808DataRepository(string connectionString)
        {
            Context = new DbSession(DatabaseType.SqlServer9, connectionString);

        }
        public int AddMsgLog(JT808MsgLog log)
        {
            return Context.Insert(log);
        }

        public int AddJT808Terminal(JT808Terminal entity)
        {
            return Context.Insert(entity);
        }
        public int UpdateJT808Terminal(JT808Terminal entity)
        {
            return Context.Save(entity);
        }

        public JT808Terminal getTerminalByCode(string code)
        {
            return Context.From<JT808Terminal>().Where(JT808Terminal._.Code == code).First();
        }
    }


    public class DB { public static readonly DbSession Context = new DbSession(DatabaseType.SqlServer9, "Server=127.0.0.1;Database=JT808_Server;Uid=sa;Pwd=Ecvv2016;Pooling=True;Connect Timeout=300;Connection Reset=FALSE"); }


}
